package com.common.dialog;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.ViewGroup;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;

import java.util.List;

import top.limuyang2.customldialog.BottomTextListDialog;
import top.limuyang2.customldialog.IOSMsgDialog;
import top.limuyang2.customldialog.MaterialMsgDialog;
import top.limuyang2.customldialog.adapter.BottomTextListAdapter;

/**
 * 弹框工具
 * @author mrwim
 * @version 1.0
 */
public class MyDialog {
    /**
     * 返回android meterial风格弹框
     * @param manager
     * @param title
     * @param message
     * @param negStr
     * @param negClick
     * @param posStr
     * @param posClick
     * @return
     */
    public static MaterialMsgDialog showMaterialDialog(FragmentManager manager, String title, String message,  String negStr,View.OnClickListener negClick, String posStr, View.OnClickListener posClick) {
       return MaterialMsgDialog.Companion.init(manager).setTitle(title).setMessage(message).setNegativeButton(negStr, negClick).setPositiveButton(posStr, posClick).setCancelableOutside(false);
    }

    /**
     * 返回 ios风格对话框
     * @param manager
     * @param title
     * @param message
     * @param negStr
     * @param negClick
     * @param posStr
     * @param posClick
     * @return
     */
    public static IOSMsgDialog showIOSDialog(FragmentManager manager, String title, String message,String negStr, View.OnClickListener negClick,  String posStr, View.OnClickListener posClick){
        return IOSMsgDialog.Companion.init(manager).setTitle(title).setMessage(message).setNegativeButton(negStr, negClick).setPositiveButton(posStr, posClick).setCancelableOutside(false);
    }

    /**
     * 返回底部选项框
     * @param manager
     * @param onItemClickListener
     * @param list
     * @return
     */
    public static BottomTextListDialog showSheetDialog(FragmentManager manager, BottomTextListAdapter.OnItemClickListener onItemClickListener, List<String> list){
        return  BottomTextListDialog.Companion.init(manager).setOnItemClickListener(onItemClickListener).setTextList(list).setCancelableOutside(true);
    }

    /**
     * 二级条件选择器
     * @param context
     * @param title
     * @param listener
     * @return
     */
    public static OptionsPickerView showOptionsPickView(Context context, ViewGroup view, String title, String label1, String label2, List<String> list1, List<String> list2, OnOptionsSelectListener listener){
       OptionsPickerView optionsPickerView = new OptionsPickerBuilder(context, listener)
                .setTitleText(title)
                .setContentTextSize(20)
                .setDividerColor(Color.GRAY)
                .setSelectOptions(0, 1)
                .setBgColor(Color.WHITE)
                .setTitleBgColor(Color.WHITE)
                .setTitleColor(Color.LTGRAY)
                .setCancelColor(Color.BLACK)
                .setSubmitColor(Color.BLUE)
                 .setLabels(label1,label2,"")
                .setTextColorCenter(Color.LTGRAY)
                .isCenterLabel(false)
               .setDecorView(view)
                .build();
        optionsPickerView.setNPicker(list1, list2,null);
        return optionsPickerView;
    }
    /**
     * 二级条件选择器 联动 List<String> List<List<String>>
     * @param context
     * @param title
     * @param listener
     * @return
     */
    public static OptionsPickerView showTwoLD(Context context, ViewGroup view, String title, String label1, String label2, List<String> list1, List<List<String>> list2, OnOptionsSelectListener listener){
        OptionsPickerView optionsPickerView = new OptionsPickerBuilder(context, listener)
                .setTitleText(title)
                .setContentTextSize(20)
                .setDividerColor(Color.GRAY)
                .setSelectOptions(0, 1)
                .setBgColor(Color.WHITE)
                .setTitleBgColor(Color.WHITE)
                .setTitleColor(Color.LTGRAY)
                .setCancelColor(Color.BLACK)
                .setSubmitColor(Color.BLUE)
                .setLabels(label1,label2,"")
                .setTextColorCenter(Color.LTGRAY)
                .isCenterLabel(false)
                .setDecorView(view)
                .build();
        optionsPickerView.setPicker(list1, list2);
        return optionsPickerView;
    }
    /**
     * 三级条件选择器 联动 List<String> List<List<String>> List<List<List<String>>>
     * @param context
     * @param title
     * @param listener
     * @return
     */
    public static OptionsPickerView showThreeLD(Context context, ViewGroup view, String title, String label1, String label2, List<String> list1, List<List<String>> list2,List<List<List<String>>> list3, OnOptionsSelectListener listener){
        OptionsPickerView optionsPickerView = new OptionsPickerBuilder(context, listener)
                .setTitleText(title)
                .setContentTextSize(20)
                .setDividerColor(Color.GRAY)
                .setSelectOptions(0, 1)
                .setBgColor(Color.WHITE)
                .setTitleBgColor(Color.WHITE)
                .setTitleColor(Color.LTGRAY)
                .setCancelColor(Color.BLACK)
                .setSubmitColor(Color.BLUE)
                .setLabels(label1,label2,"")
                .setTextColorCenter(Color.LTGRAY)
                .isCenterLabel(false)
                .setDecorView(view)
                .build();
        optionsPickerView.setPicker(list1, list2,list3);
        return optionsPickerView;
    }
}
